<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>ajax新增页</title>
<script type="text/javascript" src="./static/js/jquery.min.js"></script>
</head>
<body>
<form action="employee/insert" method="post" id="in" name="myForm">
		姓名：<input type="text" name="name" id="n" placeholder="请输入姓名"/><br /> 
		年龄:<input type="text" name="age" id="a" placeholder="请输入年龄"/><br /> 
		薪资：<input type="text" name="salary" id="s" placeholder="请输入薪资"/> <br />
		入职日期：<input type="text" name="hireDate" id="h" placeholder="请输入入职日期"/> <br /> <br />
		<input type="button" value="提交" onclick="formSub( )" />
	</form>
	<script>
	
	function formSub( ) {
		var name = $("#n").val();
		var age = $("#a").val();
		var salary = $("#s").val();
		var hireDate = $("#h").val();
			$.ajax({
			data : { 
				"name" : name,
				"age" : age,
				"salary" : salary,
				"hireDate" : hireDate 
			},
			type : "POST",
			dataType : 'json',
			url : "employee/insert",
		/* 	error : function(data) {
				alert("error:"+data);
			}, */
			success : function(data) {
				window.location.href="http://localhost:8080/springMvcAndMybatisAjax/employee.html";
				//alert("success:"+data);			
			}
			})}
	</script>
</body>
</html>